import { useAuth } from "../components/AuthContext";
import { useNavigate,useLocation } from "react-router";

export default function LoginPage() {
  const { logAction, isPending } = useAuth();

  return (
    <main className="bg-gray-100 h-screen w-screen flex items-center justify-center px-4">
      <div className="bg-white p-6 rounded-lg shadow-md w-full max-w-md">
        <h1 className="text-2xl font-bold text-gray-800 mb-4 text-center">
          Login
        </h1>
        <form className="space-y-4" action={logAction}>
          <input type="hidden" name="type" value="login"/>
          <input
            name="email"
            type="email"
            placeholder="Email"
            className="w-full p-2 border rounded"
            required=""
            defaultValue="admin1@email.com"
          />
          <input
            name="password"
            type="password"
            placeholder="Password"
            className="w-full p-2 border rounded"
            required=""
            defaultValue="admin1pass"
          />
          <p className="text-red-500 mb-4 hidden text-center">
            Invalid email or password
          </p>
          <button
            type="submit"
            className="w-full bg-blue-500 text-white p-2 rounded hover:bg-blue-600"
          >
            Login
          </button>
        </form>
        <p className="mt-4 text-gray-600 text-center">
          Don't have an account?{" "}
          <a href="register.html" className="text-blue-500 hover:underline">
            Register
          </a>
        </p>
      </div>
    </main>
  );
}
